
/**
 * 审批记录弹窗控制器
 */
import tem from './index.html'
import './index.less'
import $_fn from '~plugins'
class recordCtrl {
  constructor($scope,$rootScope,http,$ui,$state,$location,$timeout) {
    $scope.param = {}
    $scope.redErr = {}
    console.log('$scope.params', $scope.params,$location,$location.path(),$location.search())
    $scope.cancel = function () {
      $rootScope.$uiDirectiveModal.close() //关闭方法
    }
    //警告提示
    $scope.errorToast = function(text) {
      $ui.toast({text:text,type:'warning',position:'center',appendTo:'.wp-container'});
    }
    //成功提示
    $scope.successToast = function(text) {
        $ui.toast({text:text,type:'success',position:'center',appendTo:'.wp-container'});
    }
    
    //分页参数
    $scope.page = {
      current: 1
    }
    //获取数据的入参
    $scope.param = {
      Table:  $scope.params.Table,
      tableId: $scope.params.oid
    }
    //获取列表数据的函数
    $scope.getDada = function(page){
      $scope.param.pageNum = page
      http.post('selectPageLogList.do',$scope.param,function (data) {
        if(data.errcode == 1){
          $scope.$apply(function(){
            let _data = data.data
            $scope.data = data.data
            $scope.dataList = data.data.list
            //分页所需数据
            $scope.page.pageNum =  $scope.page.current
            $scope.page.pageSize = _data.pageSize
            $scope.page.total = _data.total

          })
        }else{
          // $scope.errorToast(data.errmsg || '请求失败！')
        }
      })
    }
    $scope.getDada(1)

  }
}


recordCtrl.$inject = ['$scope','$rootScope','http','$ui','$state','$location','$timeout','$interval']
module.exports = angular.module('directive.record', []).directive('record', function() {
  return {
    restrict: 'E',
    template: tem,
    replace:true,
    controller: recordCtrl,
    scope: {
      params: '<'
    },
    link:function(){
      $_fn.clickBind()
    }
  }
}).name